package com.ww.grtsmanager.controller;

import com.ww.grtsmanager.bean.Chapter;
import com.ww.grtsmanager.service.ChapterService;
import com.ww.grtsmanager.vo.EduResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/chapter")
public class ChapterController {
    @Autowired
    private ChapterService chapterService;
    @RequestMapping("/addChapter")
    public EduResult addChapter(@RequestBody Chapter chapter){
        chapterService.addChapter(chapter);
        return EduResult.ok();
    }
    @RequestMapping("/deleteChapter")
    public EduResult deleteChapter(@PathVariable Integer id){
        chapterService.deleteChapter(id);
        return EduResult.ok();
    }
    @RequestMapping("/sort/{chapterId}/{sort}")
    public EduResult sort(@PathVariable Integer chapterId, @PathVariable String sort){
        chapterService.sort(chapterId,sort);
        return EduResult.ok();
    }
}
